const Mock = require('mockjs');

const Random = Mock.Random;

let Result = {
    code: 200,
    msg: '获取成功',
    data: null
};

// 获取验证码
Mock.mock('/captcha','get',() => {
    Result.data = {
        token: Random.string(32),
        captchaImg: Random.dataImage('92x40','12345')
    };
    return Result;
});

// 用户登录
Mock.mock('/login','post',() => {
    // 无法在header中传入jwt
    Result.code = 200;
    Result.msg = '啦啦啦啦啦';
    return Result;
});

// 获取用户信息
Mock.mock('/sys/userInfo','get',() => {
    Result.data = {
        id: "1",
        username: "张三",
        password: "123",
        avatar: "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1"
    };
    return Result;
});

// 修改用户信息
Mock.mock('/sys/modifyUserInfo','post',(res) => {
    Result.data = JSON.parse(res.body);
    return Result;
});

// 退出登录
Mock.mock('/logout','post',(res) => {
    return Result;
});

// 获取tabs列表
Mock.mock('/sys/menu/nav','get',(res) => {
    let nav = [
        {
            name: 'SysMange',
            title: '系统管理',
            icon: 'el-icon-s-operation',
            path: '',
            component: '',
            children: [
                {
                    name: 'SysUser',
                    title: '用户管理',
                    icon: 'el-icon-user-solid',
                    path: '/sys/user',
                    component: 'sys/User',
                    children: []
                },
                {
                    name: 'SysRole',
                    title: '角色管理',
                    icon: 'el-icon-s-check',
                    path: '/sys/role',
                    component: 'sys/Role',
                    children: []
                },
                {
                    name: 'SysMenu',
                    title: '菜单管理',
                    icon: 'el-icon-menu',
                    path: '/sys/menu',
                    component: 'sys/Menu',
                    children: []
                }
            ]
        },
        {
            name: 'SysTool',
            title: '系统工具',
            icon: 'el-icon-s-tools',
            path: '',
            component: '',
            children: [
                {
                    name: 'SysNotebook',
                    title: '数字字典',
                    icon: 'el-icon-notebook-1',
                    path: '',
                    component: '',
                    children: []
                },
            ]
        }
    ];
    let perms = [];
    Result.data = {
        nav: nav,
        perms: perms
    };
    return Result;
});

// 获取菜单列表数据
Mock.mock('/sys/menu/list','get',(res) => {
    let menuList = [
        {
            id: 1,
            created: '2021-01-15T18:58:18',
            updated: '2021-01-15T18:58:18',
            status: 1,
            parentId: 0,
            name: '系统管理',
            path: '',
            perms: 'sys:manage',
            component: '',
            type: 0,
            icon: 'el-icon-s-operation',
            orderNum: 1,
            children: [
                {
                    id: 2,
                    created: '2021-01-15T18:58:18',
                    updated: '2021-01-15T18:58:18',
                    status: 1,
                    parentId: 1,
                    name: '用户管理',
                    path: '/sys/user',
                    perms: 'sys:user:list',
                    component: 'sys/User',
                    type: 1,
                    icon: 'el-icon-user-solid',
                    orderNum: 1,
                    children: [
                        {
                            id: 9,
                            created: '2021-01-17T21:48:32',
                            updated: null,
                            status: 1,
                            parentId: 2,
                            name: '添加用户',
                            path: null,
                            perms: 'sys:user:save',
                            component: null,
                            type: 2,
                            icon: null,
                            orderNum: 1,
                            children: []
                        },
                        {
                            id: 10,
                            created: '2021-01-17T21:48:32',
                            updated: null,
                            status: 1,
                            parentId: 2,
                            name: '修改用户',
                            path: null,
                            perms: 'sys:user:update',
                            component: null,
                            type: 2,
                            icon: null,
                            orderNum: 2,
                            children: []
                        },
                        {
                            id: 11,
                            created: '2021-01-17T21:48:32',
                            updated: null,
                            status: 1,
                            parentId: 2,
                            name: '删除用户',
                            path: null,
                            perms: 'sys:user:delete',
                            component: null,
                            type: 2,
                            icon: null,
                            orderNum: 3,
                            children: []
                        },
                        {
                            id: 12,
                            created: '2021-01-17T21:48:32',
                            updated: null,
                            status: 1,
                            parentId: 2,
                            name: '分配角色',
                            path: null,
                            perms: 'sys:user:role',
                            component: null,
                            type: 2,
                            icon: null,
                            orderNum: 4,
                            children: []
                        },
                        {
                            id: 13,
                            created: '2021-01-17T21:48:32',
                            updated: null,
                            status: 1,
                            parentId: 2,
                            name: '重置密码',
                            path: null,
                            perms: 'sys:user:repass',
                            component: null,
                            type: 2,
                            icon: null,
                            orderNum: 5,
                            children: []
                        },
                    ]
                },
                {
                    id: 3,
                    created: '2021-01-15T18:58:18',
                    updated: '2021-01-15T18:58:18',
                    status: 1,
                    parentId: 1,
                    name: '角色管理',
                    path: '/sys/role',
                    perms: 'sys:role:list',
                    component: 'sys/Role',
                    type: 1,
                    icon: 'el-icon-s-check',
                    orderNum: 2,
                    children: []
                },
                {
                    id: 4,
                    created: '2021-01-15T18:58:18',
                    updated: '2021-01-15T18:58:18',
                    status: 1,
                    parentId: 1,
                    name: '菜单管理',
                    path: '/sys/menu',
                    perms: 'sys:menu:list',
                    component: 'sys/Menu',
                    type: 1,
                    icon: 'el-icon-menu',
                    orderNum: 3,
                    children: []
                },
            ]
        },
        {
            id: 5,
            created: '2021-01-15T18:58:18',
            updated: '2021-01-15T18:58:18',
            status: 1,
            parentId: 0,
            name: '系统工具',
            path: '',
            perms: 'sys:tools',
            component: '',
            type: 0,
            icon: 'el-icon-s-tools',
            orderNum: 2,
            children: [
                {
                    id: 6,
                    created: '2021-01-15T18:58:18',
                    updated: '2021-01-15T18:58:18',
                    status: 1,
                    parentId: 5,
                    name: '数字字典',
                    path: '/sys/dicts',
                    perms: 'sys:dict:list',
                    component: 'sys/Dict',
                    type: 1,
                    icon: 'el-icon-notebook-1',
                    orderNum: 1,
                    children: []
                },
            ]
        },
    ];
    Result.data = menuList;
    return Result;
});

// 获取菜单信息
Mock.mock(RegExp('/sys/menu/info/*'), 'get', () => {

    let info = {
        id: 2,
        created: '2021-01-15T18:58:18',
        updated: '2021-01-15T18:58:18',
        status: 1,
        parentId: 1,
        name: '用户管理',
        path: '/sys/user',
        perms: 'sys:user:list',
        component: 'sys/User',
        type: 1,
        icon: 'el-icon-user-solid',
        orderNum: 1,
    }
    Result.data = info;
    return Result;
})

// 菜单添加更新删除数据
Mock.mock(RegExp('/sys/menu/*'), 'post', () => {

    return Result;
});

// 角色添加更新删除数据
Mock.mock(RegExp('/sys/role/*'), 'post', () => {

    return Result;
});

// 获取角色列表数据
Mock.mock(RegExp('/sys/role/list*'),'get',(res) => {
    let roleList = [
        {
            id: 3,
            created: '2021-01-15T18:58:18',
            updated: '2021-01-15T18:58:18',
            name: '普通用户',
            code: 'normal',
            remark: '只有基本查看功能',
            status: 1,
            menuIds: []
        },
        {
            id: 6,
            created: '2021-01-15T18:58:18',
            updated: '2021-01-15T18:58:18',
            name: '超级管理员',
            code: 'admin',
            remark: '系统默认最高权限，不可以编辑和任意修改',
            status: 1,
            menuIds: []
        },

    ];
    Result.data = {
        roleList,
        total: 2,
        size: 10,
        current: 1,
        orders: [],
        optimizeCountSql: true,
        hitCount: false,
        countId: null,
        maxLimit: null,
        searchCount: true,
        pages: 1
    };
    return Result;
});

// 角色信息
Mock.mock(RegExp('/sys/role/info/*'),'get',(res) => {
    let roleInfo = {
        id: 3,
        created: '2021-01-15T18:58:18',
        updated: '2021-01-15T18:58:18',
        name: '普通用户',
        code: 'normal',
        remark: '只有基本查看功能',
        status: 1,
        menuIds: [1,2,5,9]
    };
    Result.data = roleInfo;
    return Result;
});

// 用户添加更新删除数据
Mock.mock(RegExp('/sys/user/*'), 'post', () => {

    return Result;
});

// 获取用户信息列表
Mock.mock(RegExp('/sys/user/list*'), 'get', () => {
    let userList = [
        {
            "id": 1,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "admin",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "test@qq.com",
            "phone": "1871945139",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 6, "name": "超级管理员"},
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 2,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "testtesttesetteset",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "1731896174@qq.com",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 1,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "admin",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "test@qq.com",
            "phone": "1871945139",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 6, "name": "超级管理员"},
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 2,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "testtesttesetteset",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "1731896174@qq.com",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 1,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "admin",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "test@qq.com",
            "phone": "1871945139",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 6, "name": "超级管理员"},
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 2,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "testtesttesetteset",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "1731896174@qq.com",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 1,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "admin",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "test@qq.com",
            "phone": "1871945139",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 6, "name": "超级管理员"},
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 2,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "testtesttesetteset",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "1731896174@qq.com",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 1,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "admin",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "test@qq.com",
            "phone": "1871945139",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 6, "name": "超级管理员"},
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 2,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "testtesttesetteset",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "1731896174@qq.com",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 1,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "admin",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "test@qq.com",
            "phone": "1871945139",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 6, "name": "超级管理员"},
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 2,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "testtesttesetteset",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "1731896174@qq.com",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 1,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "admin",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "test@qq.com",
            "phone": "1871945139",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 6, "name": "超级管理员"},
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 2,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "testtesttesetteset",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "1731896174@qq.com",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 1,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "admin",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "test@qq.com",
            "phone": "1871945139",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 6, "name": "超级管理员"},
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 2,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "testtesttesetteset",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "1731896174@qq.com",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 1,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "admin",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "test@qq.com",
            "phone": "1871945139",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 6, "name": "超级管理员"},
                {"id": 3, "name": "普通用户"},
            ]
        },
        {
            "id": 2,
            "created": "2021-01-30T08:20:22",
            "updated": "2021-01-30T08:55:57",
            "status": 1,
            "username": "testtesttesetteset",
            "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
            "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
            "email": "1731896174@qq.com",
            "city": null,
            "lastLogin": null,
            "roles": [
                {"id": 3, "name": "普通用户"},
            ]
        },
    ];
    Result.data = {
        userList,
        total: 2,
        size: 10,
        current: 1,
        orders: [],
        optimizeCountSql: true,
        hitCount: false,
        countId: null,
        maxLimit: null,
        searchCount: true,
        pages: 1
    };
    return Result;
});

// 用户信息
Mock.mock(RegExp('/sys/user/info/*'),'get',(res) => {
    let userInfo = {
        "id": 1,
        "created": "2021-01-30T08:20:22",
        "updated": "2021-01-30T08:55:57",
        "status": 1,
        "username": "admin",
        "password": "$2a$10$0ilP4ZD1kLugYwLCs4pmb.ZT9cFqzOZTNaMiHxrBnVIQUGUwEvBIO",
        "avatar": "https://tse4-mm.cn.bing.net/th/id/OIP-C.fR9s9Ys1hzRMIURSfhgBAwAAAA?pid=ImgDet&rs=1",
        "email": "test@qq.com",
        "phone": "1871945139",
        "city": null,
        "lastLogin": null,
        "roles": [
            {"id": 6, "name": "超级管理员"},
            {"id": 3, "name": "普通用户"},
        ]
    };
    Result.data = userInfo;
    return Result;
});

// 首页折线图数据
Mock.mock('/chartData', 'get', (res) => {
    let chartData = {
        columns: ['日期', '营业额'],
        rows: [
            { '日期': '21/1/1', '营业额': 123 },
            { '日期': '21/1/2', '营业额': 1223 },
            { '日期': '21/1/3', '营业额': 2123 },
            { '日期': '21/1/4', '营业额': 4123 },
            { '日期': '21/1/5', '营业额': 3123 },
            { '日期': '21/1/6', '营业额': 7123 },
            { '日期': '21/1/7', '营业额': 123 },
            { '日期': '21/1/8', '营业额': 1223 },
            { '日期': '21/1/9', '营业额': 2123 },
            { '日期': '21/1/10', '营业额': 4123 },
            { '日期': '21/1/11', '营业额': 3123 },
            { '日期': '21/1/12', '营业额': 7123 },
            { '日期': '21/1/13', '营业额': 123 },
            { '日期': '21/1/14', '营业额': 1223 },
            { '日期': '21/1/15', '营业额': 2123 },
            { '日期': '21/1/16', '营业额': 4123 },
            { '日期': '21/1/17', '营业额': 3123 },
            { '日期': '21/1/18', '营业额': 7123 },
            { '日期': '21/1/19', '营业额': 123 },
            { '日期': '21/1/20', '营业额': 1223 },
            { '日期': '21/1/21', '营业额': 2123 },
            { '日期': '21/1/22', '营业额': 4123 },
            { '日期': '21/1/23', '营业额': 3123 },
            { '日期': '21/1/24', '营业额': 7123 },
            { '日期': '21/1/25', '营业额': 7123 },
            { '日期': '21/1/26', '营业额': 7123 },
            { '日期': '21/1/27', '营业额': 7123 },
            { '日期': '21/1/28', '营业额': 7123 },
            { '日期': '21/1/29', '营业额': 7123 },
            { '日期': '21/1/30', '营业额': 7123 },
        ]
    };
    Result.data = chartData;
    return Result;
})